package com.voxel.sense.infomsg.data.bean;

import com.example.com.common.widget.diffui.DiffUiDataCallBack;

import java.util.List;

/**
 * 图标的bean类
 * Created by ChenYiYao on 2018/8/1.
 */
public class RealCharBean<T> implements DiffUiDataCallBack.UidataDiffer<RealCharBean> {
    private String paramUnit; //元素单位
    private String paramName; //名称
    private List<ValueBean> paramValue; //值
    private T note; //额外数据

    public String getParamUnit() {
        return paramUnit;
    }

    public void setParamUnit(String paramUnit) {
        this.paramUnit = paramUnit;
    }

    public String getParamName() {
        return paramName;
    }

    public void setParamName(String paramName) {
        this.paramName = paramName;
    }

    public List<ValueBean> getParamValue() {
        return paramValue;
    }

    public void setParamValue(List<ValueBean> paramValue) {
        this.paramValue = paramValue;
    }

    public T getNote() {
        return note;
    }

    public void setNote(T note) {
        this.note = note;
    }

    @Override
    public boolean isSame(RealCharBean old) {
        return paramName.equals(old.paramName);
    }

    @Override
    public boolean isDataContentSame(RealCharBean old) {
        boolean flag = false;
        if (!(paramValue == null && old.paramValue == null)) {
            return false;
        } else if (!paramUnit.equals(old.paramUnit)) {
            return false;
        } else if (paramValue.size() == old.paramValue.size()) {
            //只有最后一个数据是会更新的，历史数据不会再改变，对比最后一个即可
            ValueBean valueBean = paramValue.get(paramValue.size() - 1);
            ValueBean oldBean = (ValueBean) old.paramValue.get(paramValue.size() - 1);
            flag = valueBean.getValue().equals(oldBean.getValue());
        }
        return flag;
    }

    public static class ValueBean {
        String value;
        long time;

        public ValueBean(String value, long time) {
            this.value = value;
            this.time = time;
        }

        public String getValue() {
            return value;
        }

        public void setValue(String value) {
            this.value = value;
        }

        public long getTime() {
            return time;
        }

        public void setTime(long time) {
            this.time = time;
        }
    }
}
